package com.itheima.configurations;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MybatisConfig {


    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        // 创建MybatisPlusInterceptor拦截器对象
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        // 创建内部分页拦截器对象,并且指定拦截的数据库类型
        PaginationInnerInterceptor  innerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);

        //  把内部分页拦截器对象 交给MybatisPlusInterceptor拦截器对象 管理
         mybatisPlusInterceptor.addInnerInterceptor(innerInterceptor);

        //  将MybatisPlusInterceptor拦截器对象返回出去

        return mybatisPlusInterceptor ;
    }

}
